
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:ace="http://www.icefaces.org/icefaces/components" xmlns:ice="http://www.icesoft.com/icefaces/component" xmlns:icecore="http://www.icefaces.org/icefaces/core" xmlns:ui="http://java.sun.com/jsf/facelets">
    
     
	<ui:composition template="../../WEB-INF/templates/template.xhtml">


		<ui:param name="title" value="Fact Entry System"/>
        	
		<ui:define name="header">
			<ui:include src="../../WEB-INF/templates/header.xhtml"/> 
		</ui:define>
		
		<ui:define name="menu">		
			<ui:include src="../../WEB-INF/templates/menuLeft.xhtml"/>               
		</ui:define>
		
		<ui:define name="content">
			
			<style type="text/css">
			               
			.icePnlGrdFtr {
			    padding-left: 120px;
			    padding-top: 60px;
			}
							
            </style>
<script type="text/javascript">
	function deleteConfirmation(nodeId,label)
	{
		document.getElementById("deleteMsg").innerHTML="Node Name :"+label;
		document.getElementById("form:nodeId").value=nodeId;
		confirmation.show();
	}
	function setEditId(userId) 
	{

	    document.getElementById("form:editNodeId").value=userId;
	}
</script>	
            
			<h:panelGrid styleClass="managementHeaderTable" width="100%" columns="4" cellspacing="3" cellpadding="3">
            <h:outputText value="Node Hierarchy Management" />              
				 <h:outputText value="Segment"/>
            	 <ice:selectOneMenu styleClass="roleSelectBox"  partialSubmit="true" value="#{nodeHierarchyBean.segmentId}" id="segmentId" valueChangeListener="#{nodeHierarchyBean.toggleSegmentId}" >
            		         <f:selectItem itemLabel="Select a Segment" itemValue="0" />
	   						<f:selectItems value="#{segmentBean.segmentSelectList}" />
	 			</ice:selectOneMenu>
	 			
	 			<h:commandButton value="Add New Node"  actionListener="#{nodeHierarchyBean.openEvent}"/>
	 				   
            </h:panelGrid> 
            <h:messages  globalOnly="true"  style="color:green"/>

		  <!-- Paginator with page controls -->
                <ice:dataPaginator id="dataScroll_3"
                                   for="nodeList"
                                   paginator="true"
                                   fastStep="3"
                                   paginatorMaxPages="4">
                    <f:facet name="first">
                        <ice:graphicImage
                            url="../xmlhttp/css/rime/css-images/arrow-first.gif"
                            style="border:none;"
                            title="First Page"/>
                    </f:facet>
                    <f:facet name="last">
                        <ice:graphicImage
                            url="../xmlhttp/css/rime/css-images/arrow-last.gif"
                            style="border:none;"
                            title="Last Page"/>
                    </f:facet>
                    <f:facet name="previous">
                        <ice:graphicImage
                            url="../xmlhttp/css/rime/css-images/arrow-previous.gif"
                            style="border:none;"
                            title="Previous Page"/>
                    </f:facet>
                    <f:facet name="next">
                        <ice:graphicImage
                            url="../xmlhttp/css/rime/css-images/arrow-next.gif"
                            style="border:none;"
                            title="Next Page"/>
                    </f:facet>
                    <f:facet name="fastforward">
                        <ice:graphicImage url="../xmlhttp/css/rime/css-images/arrow-ff.gif"
                                          style="border:none;"
                                          title="Fast Forward"/>
                    </f:facet>
                    <f:facet name="fastrewind">
                        <ice:graphicImage url="../xmlhttp/css/rime/css-images/arrow-fr.gif"
                                          style="border:none;"
                                          title="Fast Backwards"/>
                    </f:facet>
                </ice:dataPaginator>
                
                <!-- Display counts about the table and the currently displayed page -->
                <ice:dataPaginator id="dataScroll_2" for="nodeList"
                                   rowsCountVar="rowsCount"
                                   displayedRowsCountVar="displayedRowsCount"
                                   firstRowIndexVar="firstRowIndex"
                                   lastRowIndexVar="lastRowIndex"
                                   pageCountVar="pageCount"
                                   pageIndexVar="pageIndex">
                    <ice:outputFormat
                        value="{0} Nodes found, displaying {1} Node(s) from {2} to {3}. Page {4} / {5}."
                        styleClass="standard">
                        <f:param value="#{rowsCount}"/>
                        <f:param value="#{displayedRowsCount}"/>
                        <f:param value="#{firstRowIndex}"/>
                        <f:param value="#{lastRowIndex}"/>
                        <f:param value="#{pageIndex}"/>
                        <f:param value="#{pageCount}"/>
                    </ice:outputFormat>
                </ice:dataPaginator>
                			
	      <ice:dataTable
                    rows="20"
                    id="nodeList"
                    value="#{nodeHierarchyBean.nodeList}"
                    var="node" varStatus="rowInfo"  columnWidths="50px,50px,400px,100px,100px,200px,80px,100px,100px" >
                    
                    <!-- Serial number -->
                    <ice:column styleClass="col_slNo">
                        <f:facet name="header">
                            <ice:outputText value="Serial"/>
                        </f:facet>

                        <ice:outputText value="#{rowInfo.index+1}"/>
                        
                    </ice:column>
                    
                    <!-- Node Id -->
                    <ice:column styleClass="col_slNo">
                        <f:facet name="header">
                            <ice:outputText value="Node Id"/>
                        </f:facet>
                        <ice:outputText value="#{node.nodeId}"/>
                       
            
                        
                    </ice:column>
                                        
                    <!-- Node Name -->
                    <ice:column>
                        <f:facet name="header">
                            <ice:outputText value="Node Name"/>
                        </f:facet>
                        <ice:outputText value="#{node.vizString}"/>
                    </ice:column>
                    
                    <!-- Data Type -->
                    <ice:column styleClass="col_slNo">
                        <f:facet name="header">
                            <ice:outputText value="Data Type"/>
                        </f:facet>
                        <ice:outputText value="#{node.dataType}"/>
                    </ice:column>
                    
					<!-- Node Type -->
                    <ice:column styleClass="col_slNo">
                        <f:facet name="header">
                            <ice:outputText value="Node Type"/>
                        </f:facet>
                        <ice:outputText value="#{node.nodeTypeName}"/>
                    </ice:column>
                    
                    <!-- Segment -->
                    <ice:column styleClass="col_slNo">
                        <f:facet name="header">
                            <ice:outputText value="Segment"/>
                        </f:facet>
                        <ice:outputText value="#{node.segmentName}"/>
                    </ice:column>
                    
                    <!-- Parent Node -->
                    <ice:column styleClass="col_slNo">
                        <f:facet name="header">
                            <ice:outputText value="Parent Node"/>
                        </f:facet>
                        <ice:outputText value="#{node.parentNode}"/>
                    </ice:column>
                    

                    <!-- Edit -->
                    <ice:column styleClass="col_edit">
                        <f:facet name="header">
                            <ice:outputText value="Edit"/>
                          		 
                        </f:facet>


						<h:commandButton id="edit" value="Edit" onclick="setEditId('#{node.nodeId}')" actionListener="#{nodeHierarchyBean.openEditEvent}" type="button"
				 					image="/FACTENTRY/javax.faces.resource/edit.png.jsf?ln=images"/>
				 					
                        
                    </ice:column>
                    
                    <!-- Delete -->
                    <ice:column styleClass="col_delete">
                        <f:facet name="header">
                            <ice:outputText value="Delete"/>
                        </f:facet>
                                  
                                <a href="#" onclick="deleteConfirmation('#{node.nodeId}','#{node.label}')">
									<h:graphicImage library="images" name="delete.png"/>
								</a>
								
                    </ice:column>
                    
                    
                </ice:dataTable>
                
                	
           


			<ice:panelPopup visible="#{nodeHierarchyBean.opened}"
                            rendered="true"
                            modal="true"
                            autoCentre="true" style="width: 550px; height: 405px;  background: #FFFFFF;">
                <f:facet name="header">
                    <h:panelGroup>
                        <h:panelGroup style="float: left;padding-left:10px;">
                            New Node Entry Form
                        </h:panelGroup>
                        <h:panelGroup style="float: right;">
                            <h:commandButton image="/FACTENTRY/javax.faces.resource/popup-close.png.jsf?ln=images"
                                             alt="Close" title="Close"      type="button"                    
                                             style="height: 11px; width: 11px; border: 0;"
                                             actionListener="#{nodeHierarchyBean.closeEvent}"  />
                        </h:panelGroup>
                    </h:panelGroup>
                </f:facet>
                <f:facet name="body">
                
                	<ice:panelGrid id="newNodeContent"
                       width="100%" cellpadding="0"
                       cellspacing="4" columns="2" rendered="true"
                       styleClass="popupModalBody" columnWidths="20px,400px"> 
                       
                       <h:outputText value="Node Name"/>
            		   <h:inputText  styleClass="commonText" value="#{nodeHierarchyBean.node.label}" id="nodeName"/>            		   
					   <h:outputText value="" />
            		   <h:message for="nodeName" style="color:red"/>
            		   	
					   
					   <h:outputText value="Description"/>
            		   <h:inputText  styleClass="commonText" value="#{nodeHierarchyBean.node.description}" id="nodeDescription" redisplay="true" />            		   
					   <h:outputText value="" />
            		   <h:message for="nodeDescription" style="color:red"/>
					   
					   <h:outputText value="Data Type"/>
					   <ice:selectOneMenu styleClass="roleSelectBox"  partialSubmit="false" value="#{nodeHierarchyBean.node.dataType}" id="dataType" >
            		         <f:selectItem itemLabel="Select Data Type" itemValue="0" />
	   						<f:selectItems value="#{nodeHierarchyBean.dataTypeSelectList}" />
	 					</ice:selectOneMenu>
					   <h:outputText value="" />
            		   <h:message for="dataType" style="color:red"/>
            		   
					   <h:outputText value="Node Type"/>
					   <ice:selectOneMenu styleClass="roleSelectBox"  partialSubmit="false" value="#{nodeHierarchyBean.node.nodeTypeId}" id="nodeType" >
            		         <f:selectItem itemLabel="Select Node Type" itemValue="0" />
	   						<f:selectItems value="#{nodeHierarchyBean.nodeTypeSelectList}" />
	 					</ice:selectOneMenu>
					   <h:outputText value="" />
            		   <h:message for="nodeType" style="color:red"/>
					   	
					   <h:outputText value="Segment"/>
            		   <h:outputText value="#{nodeHierarchyBean.segmentName}" />
            		  	
            		   
            		   <h:outputText value="Parent Node"/>
            		   <ice:selectOneMenu styleClass="roleSelectBox"    value="#{nodeHierarchyBean.node.parentNode}" id="parentNode" >
            		         <f:selectItem itemLabel="Select Parent Node" itemValue="0" />

							<f:selectItems value="#{nodeHierarchyBean.parentSelectList}" />
										  
	 				   </ice:selectOneMenu>
	 				   <h:outputText value="" />
            		   <h:message for="parentNode" style="color:red"/>
						
            		   <f:facet name="footer">
							
							<h:commandButton id="cancelButton"  actionListener="#{nodeHierarchyBean.closeEvent}"  value="Cancel" style="width:100px;height:30px;" />
							<h:outputText value="&#160;&#160;&#160;&#160;" escape="false" />
							<h:commandButton id="saveButton"  actionListener="#{nodeHierarchyBean.addNode}"  value="Save" style="width:100px;height:30px;" />
							
							
								                 
					   </f:facet>
                    
        			</ice:panelGrid>
                   
                </f:facet>
                
            </ice:panelPopup>
             <h:inputHidden  value="#{nodeHierarchyBean.node.nodeId}"  id="nodeId"  />
        
            
            <ice:panelPopup visible="#{nodeHierarchyBean.editOpened}"
                            rendered="true"
                            modal="true"
                            autoCentre="true" style="width: 550px; height: 405px;  background: #FFFFFF;">
                <f:facet name="header">
                    <h:panelGroup>
                        <h:panelGroup style="float: left;padding-left:10px;">
                            Edit Node Entry Form
                        </h:panelGroup>
                        <h:panelGroup style="float: right;">
                            <h:commandButton image="/FACTENTRY/javax.faces.resource/popup-close.png.jsf?ln=images"
                                             alt="Close" title="Close"      type="button"                    
                                             style="height: 11px; width: 11px; border: 0;"
                                             actionListener="#{nodeHierarchyBean.closeEvent}"  />
                        </h:panelGroup>
                    </h:panelGroup>
                </f:facet>
                <f:facet name="body">
                
                	<ice:panelGrid id="eidtNodeContent"
                       width="100%" cellpadding="0"
                       cellspacing="4" columns="2" rendered="true"
                       styleClass="popupModalBody" columnWidths="20px,400px"> 
                       
                       <h:outputText value="Node Name"/>
            		   <h:inputText  styleClass="commonText" value="#{nodeHierarchyBean.editNode.label}" id="editNodeName"/>            		   
					   <h:outputText value="" />
            		   <h:message for="editNodeName" style="color:red"/>
            		   	
					   
					   <h:outputText value="Description"/>
            		   <h:inputText  styleClass="commonText" value="#{nodeHierarchyBean.editNode.description}" id="editNodeDescription" redisplay="true" />            		   
					   <h:outputText value="" />
            		   <h:message for="editNodeDescription" style="color:red"/>
					   
					   <h:outputText value="Data Type"/>
					   <ice:selectOneMenu styleClass="roleSelectBox"  partialSubmit="false" value="#{nodeHierarchyBean.editNode.dataType}" id="editDataType" >
            		         <f:selectItem itemLabel="Select Data Type" itemValue="0" />
	   						<f:selectItems value="#{nodeHierarchyBean.dataTypeSelectList}" />
	 					</ice:selectOneMenu>
					   <h:outputText value="" />
            		   <h:message for="editDataType" style="color:red"/>
            		   
					   <h:outputText value="Node Type"/>
					   <ice:selectOneMenu styleClass="roleSelectBox"  partialSubmit="false" value="#{nodeHierarchyBean.editNode.nodeTypeId}" id="editNodeType" >
            		         <f:selectItem itemLabel="Select Node Type" itemValue="0" />
	   						<f:selectItems value="#{nodeHierarchyBean.nodeTypeSelectList}" />
	 					</ice:selectOneMenu>
					   <h:outputText value="" />
            		   <h:message for="editNodeType" style="color:red"/>
					   	
					   <h:outputText value="Segment"/>
            		   <h:outputText value="#{nodeHierarchyBean.segmentName}" />
            		  	
            		   
            		   <h:outputText value="Parent Node"/>
            		   <ice:selectOneMenu styleClass="roleSelectBox"    value="#{nodeHierarchyBean.editNode.parentNode}" id="editParentNode" >
            		         <f:selectItem itemLabel="Select Parent Node" itemValue="0" />

							<f:selectItems value="#{nodeHierarchyBean.parentSelectList}" />
										  
	 				   </ice:selectOneMenu>
	 				   <h:outputText value="" />
            		   <h:message for="editParentNode" style="color:red"/>
						
            		   <f:facet name="footer">
							
							<h:commandButton id="editCancelButton"  actionListener="#{nodeHierarchyBean.closeEvent}"  value="Cancel" style="width:100px;height:30px;" />
							<h:outputText value="&#160;&#160;&#160;&#160;" escape="false" />
							<h:commandButton id="editSaveButton"  actionListener="#{nodeHierarchyBean.editNode}"  value="Save" style="width:100px;height:30px;" />
							
							
								                 
					   </f:facet>
                    
        			</ice:panelGrid>
                   
                </f:facet>
                
            </ice:panelPopup>
            
            <h:inputHidden  value="#{nodeHierarchyBean.editNode.nodeId}"  id="editNodeId"  />	
            
			
		   <ace:confirmationDialog id="confirmDialog"
                                    widgetVar="confirmation"
                                    message="Are you sure you want to delete?&#60;br&#47;&#62;&#60;div id='deleteMsg'&#62;&#60;&#47;div&#62;"
                                    header="Confirmation"
                                    width="350"
                                    height="220"
                                    closable="true"
                                    position="center">
                <h:panelGrid columns="2" styleClass="centeredPanelGrid">
                    <h:commandButton id="yes" value="Yes" onclick="confirmation.hide()" actionListener="#{nodeHierarchyBean.deleteNode}"/>
                    <h:commandButton id="no"  value="No"  onclick="confirmation.hide()" />
                </h:panelGrid>
            </ace:confirmationDialog>				
            
             
            
        
        

         </ui:define>
		
		<ui:define name="footer">
	       <ui:include src="../../WEB-INF/templates/footer.xhtml"/> 
		</ui:define>
		
	</ui:composition>

</html>
